package com.chinaunicom.behavior.state;

import java.util.Random;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/8/22 14:26
 * Description: 审阅状态
 */
public class ModerationState extends State {
    public ModerationState(Document document) {
        super(document);
    }

    @Override
    public void render() {
//        System.out.println("error: 文档已保存，目前处于审批中状态......");
    }

    @Override
    public void review() {
        System.out.println("文档已保存，目前处于审批中状态......");

        // 如果审批通过则执行发表状态，不通过则执行草稿状态
        Document document = super.getDocument();
        if (new Random().nextBoolean()) {
            System.out.println("文档审批通过.........");
            document.changeState(new PublishState(document));
        } else {
            System.out.println("文档审批未通过.........");
            document.changeState(new DraftState(document));
        }
    }

    @Override
    public void publish() {
//        System.out.println("error: 文档已保存，目前处于审批中状态......");
    }
}
